/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


function editProfileValidation(){
    
        var ck_name = /^[A-Za-z0-9 ]{3,20}$/;
    var ck_minit = /^[A-Za-z ]{1,2}$/;
    var ck_email = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i ;
    var ck_username = /^[A-Za-z0-9_]{6,20}$/;
    var ck_password =  /^[A-Za-z0-9!@#$%^&*()_]{8,20}$/;
    var ck_zip =  /^\d*[0-9](|.\d*[0-9]|,\d*[0-9]{1,5})?$/;
    var ck_address = /^[A-Za-z0-9 ]{3,45}$/;
    var noerror = true; //condition
    
    if (!ck_username.test(form.username.value)) {
        document.getElementById("errorusername").innerHTML = 'Enter a valid username.';
        noerror = false;
    }else{
        document.getElementById("errorusername").innerHTML = '';
    }
    

    if (!ck_name.test(form.fname.value) || !ck_name.test(form.sname.value) || !ck_minit.test(form.minitial.value)) {
        document.getElementById("errorname").innerHTML = 'Enter full name.';
        noerror = false;
    }else{
        document.getElementById("errorname").innerHTML = '';
    }
    
    
    if (!ck_email.test(form.email.value)) {
        document.getElementById("erroremail").innerHTML = 'Enter a valid e-mail address.';
        noerror = false;
    }else{
        document.getElementById("erroremail").innerHTML = '';
    }
    
    if(!ck_address.test(form.Bhouseno.value) || !ck_address.test(form.Bst.value) || !ck_address.test(form.Bsubd.value) 
        || !ck_address.test(form.Bcity.value) || !ck_zip.test(form.Bzip.value) || !ck_address.test(form.Bcountry.value)){
        document.getElementById("errorbilling").innerHTML = 'Enter full billing address.';
        noerror = false;
    }else{
        document.getElementById("errorbilling").innerHTML = '';
    }
        
    if(!ck_address.test(form.Dhouseno.value) || !ck_address.test(form.Dst.value) || !ck_address.test(form.Dsubd.value) 
        || !ck_address.test(form.Dcity.value) || !ck_zip.test(form.Dzip.value) || !ck_address.test(form.Dcountry.value)){
        document.getElementById("errordelivery").innerHTML = 'Enter full delivery address.';
        noerror = false;
    }else{
        document.getElementById("errordelivery").innerHTML = '';
    }
    
    return noerror;
    
}
